﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECCSystem.DataAccess
{
	class ClsMailKeyName : DBObject 
	{
		public DataSet GetMailKeyName()
		{
			return RunProcedure("sp_CategoryContent_GetList", new IDataParameter[] { }, "CategoryContent");
		}

		public DataSet GetMailKeyNameByID(string strID)
		{
			SqlParameter[] parameters = new SqlParameter[] { 
															new SqlParameter("@KeyID", SqlDbType.UniqueIdentifier)
															};
			Guid guid = new Guid(strID);
			parameters[0].Value = guid;
			return RunProcedure("sp_CategoryContent_GetListByID", parameters, "CategoryContent");
		}

		public void AddMailKeyName(string strClsMailKeyNameID, string strKeyName, string strComment,int intFlg)
		{
			SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Name", SqlDbType.NVarChar, 100),
															 new SqlParameter("@Comment", SqlDbType.NVarChar, 100),
															 new SqlParameter("@IDM", SqlDbType.UniqueIdentifier),
															 new SqlParameter("@Flg", SqlDbType.Bit) };
			parameters[0].Value = strKeyName;
			parameters[1].Value = strComment;
			Guid guid = new Guid(strClsMailKeyNameID);
			parameters[2].Value = guid;
			parameters[3].Value = intFlg;
			this.RunProcedure("sp_CategoryContent_Add", parameters, "CategoryContent");
		}


		public void DeleteMailKeyName(string strID)
		{
			SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.UniqueIdentifier) };
			Guid guid = new Guid(strID);
			parameters[0].Value = guid;
			this.RunProcedure("sp_CategoryContent_Delete", parameters, "CategoryContent");
		}

		public void UpdateMailKeyName(string strID, string strIDM, string strKeyName, string strComment, int intFlg)
		{
			SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Name", SqlDbType.NVarChar, 100),
															 new SqlParameter("@Comment", SqlDbType.NVarChar, 100),
															 new SqlParameter("@ID", SqlDbType.UniqueIdentifier),
															 new SqlParameter("@IDM", SqlDbType.UniqueIdentifier),
															 new SqlParameter("@Flg", SqlDbType.Bit)};

			parameters[0].Value = strKeyName;
			parameters[1].Value = strComment;
			Guid guid1 = new Guid(strID);
			parameters[2].Value = guid1;
			Guid guid2 = new Guid(strIDM);
			parameters[3].Value = guid2;
			parameters[4].Value = intFlg;
			this.RunProcedure("sp_CategoryContent_Update", parameters, "CategoryContent");
		}
	}
}
